// 03myCenter/02sectorization/01myChange/bankCard/bankCard.js
var co = require('../../../../resource/js/common.js')
var app = getApp()
var _this

Page({
   data: {
      bankList: ''
   },

   onLoad: function (options) {
      _this = this;
      this.getBankList()
   },

   onShow: function () {
      this.getBankList()
   },

   getBankList: function () {
      var url = 'bankcard/ba/getList';
      co.getShareApi(url, {
         User_ID: app.Data.userInfo.User_ID
      }, function (res) {
         if (res.code == 0) {
            _this.setData({
               bankList: res.data
            })
         }
      })
   },
   //删除银行卡
   deleteCard(e){
      console.log('e======',e)
      var bank_account_id = e.currentTarget.dataset.bank_account_id
      console.log('bank_account_id====', bank_account_id)
      co.confirm('确认删除这张银行卡','取消','确认',function(res){
         if(res){
            co.getShareApi('bankcard/ba/deleteCard',{
               User_ID:app.Data.userInfo.User_ID,
               Bank_Account_ID: bank_account_id
            },function(res){
               console.log('删除银行卡res========',res)
               if(res.code ===0){
                  _this.getBankList()
               }
            })
         }
      })
   },
   //跳转到添加银行卡
   addBankCard: function () {
      wx.navigateTo({
         url: '/04myCenter/01myWallet/01myChange/bankCard/addBankCard/addBankCard?scene=User_ID.' + app.Data.userInfo.User_ID + '.From_Page.bankCard'
      })
   }

})